<template>
	<view>
		<!-- 顶部头像栏 -->
		<view class="">
			<view class="top_line">
				<image :src="avatar_url" style="width: 120rpx;height: 120rpx;border-radius: 50%;" mode=""></image>
			</view>
			<view class="top_line">
				{{user.nickname}}
			</view>
			<view class="top_line">
				{{user.department_name}}
			</view>
			<view class="top_line" style="color: #40A0F2;" @click="clickPhone()">
				{{user.username}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				token:'',
				member_id :'',
				company_id:'',
				company_name:'',
				
				user_id:'',
				avatar_url:'',
				user:{
					nickname:'',
					department_name:'',
					username:''
				}
			}
		},
		onLoad(option) {
			this.token = uni.getStorageSync('btlh_process_token') || '';
			this.member_id = uni.getStorageSync('btlh_process_member_id') || '';
			this.company_id = uni.getStorageSync('bthl_process_LoginCompanyId') || '';
			this.company_name = uni.getStorageSync('bthl_process_LoginCompanyName') || '';
			
			this.user_id = option.id || '';
			this.avatar_url = option.url ||'';
			this.getUserInfo();
		},
		methods: {
			// 点击电话
			clickPhone(){
				uni.makePhoneCall({
				    phoneNumber: this.user.username
				});
			},
			
			// 获取人员信息
			async getUserInfo(){
				const res = await this.$myRequest({
					url: 'AdBook/member',
					method: 'GET',
					data: {
						member_id: this.member_id,
						token: this.token,
						company_id: this.company_id,
						to_member_id: this.user_id,
					}
				});
				this.user = res.data.datas.info;
			}
		}
	}
</script>

<style lang="scss">
	.top_line{
		margin-top: 50rpx;
		display: flex;
		justify-content: center;
	}
</style>
